package day013.homework.p1;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Test {
    public static void main(String[] args) {
        double[] arr = {0.1, 0.2, 2.1, 3.2, 5.56, 7.21};
        BigDecimal[] bigArr = new BigDecimal[arr.length];
        for (int i = 0; i < arr.length; i++) {
            bigArr[i] = new BigDecimal(arr[i]);
        }

        BigDecimal sum = new BigDecimal(0);
        for (int i = 0; i < bigArr.length; i++) {
            sum = sum.add(bigArr[i]);
        }

        System.out.println(sum);
        BigDecimal avg = new BigDecimal(0);
        avg = sum.divide(new BigDecimal(bigArr.length), 2, RoundingMode.HALF_UP);
        System.out.println(avg);
    }
}
